package com.hb.znpt.activity;

import android.content.DialogInterface;
import android.os.Bundle;

import androidx.appcompat.app.AlertDialog;
import androidx.lifecycle.Observer;

import com.hb.znpt.BR;
import com.hb.znpt.R;
import com.hb.znpt.databinding.ActivityLeaseAddBinding;
import com.hb.znpt.viewmodel.LeaseAddViewModel;
import com.unitlib.base.base.BaseActivity;

public class LeaseAddActivity extends BaseActivity<ActivityLeaseAddBinding, LeaseAddViewModel> {

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_lease_add;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initData() {
        initBackTitle(binding.toolbar);
    }

    @Override
    public void initViewObservable() {
        viewModel.submitData.observe(this, new Observer<String>() {
            @Override
            public void onChanged(String s) {
                AlertDialog.Builder normalDialog = new AlertDialog.Builder(context);
                normalDialog.setMessage("请认真核对承租人信息，提交之后不能更改?")
                        .setPositiveButton("现在提交", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                viewModel.send();
                            }
                        })
                        .setNegativeButton("稍后提交", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                            }
                        }).show();
            }
        });
    }
}
